﻿@{
    ViewBag.Title = "我发起的项目";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
    bool IsIDValidate = false;//实名认证状态
    var loginUserInfo = System.Web.HttpContext.Current.Session["CurrentUser"] as LY.Entity.U_Member;
    if (loginUserInfo != null)
    {
        IsIDValidate = loginUserInfo.IsIDValidate;
    }
}
<link href="~/Scripts/laypage/skin/laypage.css" rel="stylesheet" />

<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="tab-content">
            <div class="line10"></div>
            <div class="line10"></div>
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>

            <div class="tab-content_border">
                <div class="u-center">
                    <form id="formQuery" class="form-inline" role="form">
                    </form>
                    @*  <input type="hidden" name="ID" id="hidMid" value="@Model.ID" >*@

                    <div class="menu-list">
                        <div class="ui-tab clearfix" id="group">
                            <a onclick="LoadData(1,'')" class="ui-tab-list ui-tab-list--now" href="javascript:void(0)">全部</a>
                            <a onclick="LoadData(1,210)" class="ui-tab-list" href="javascript:void(0)">众筹中</a>

                            <a onclick="LoadData(1,-2)" class="ui-tab-list" href="javascript:void(0)">审核中</a>

                            <a onclick="LoadData(1,109)" class="ui-tab-list" href="javascript:void(0)">未通过</a>

                            <a onclick="LoadData(1,220)" class="ui-tab-list" href="javascript:void(0)">已成功</a>

                            <a onclick="LoadData(1,219)" class="ui-tab-list" href="javascript:void(0)">已失败</a>
                        </div>
                        <div class="right" style="top: -20px; position: relative">
                            @* <a class="btn" href="@Url.Action("Index","Project")">发起项目</a>*@
                            <input type="button" id="sponsorPro" class="btn" value="发起项目" />
                        </div>

                    </div>
                    <div class="line10"></div>
                    <div id="gridlist" class="xjgrid">
                        <div class="grid-body">
                            <div class="grid-body-inner">
                                <table id="gridlist_detail">
                                    <thead>
                                        <tr class="thead">
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">项目信息</div>
                                            </td>
                                            <td style="width: 45%" class="sortable"></td>
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">筹集金额(元)</div>
                                            </td>
                                            <td style="width: 15%">
                                                <div style="text-align: center;">当前状态</div>
                                            </td>
                                            <td style="width: 10%">
                                                <div style="text-align: center;">操作</div>
                                            </td>
                                        </tr>
                                    </thead>
                                    <tbody class="DataList">
                                        <tr id="gridlist_tr_0" class="">
                                            <td><a class="b-l-img ThumImage" target="_blank"></a></td>
                                            <td class="td-left">
                                                <div class="clearfix">
                                                    <a class="b-l-name" href="" data-bind="ProjectName" target="_blank"></a>
                                                    <p class="b-l-tag-green" data-bind="ProjectStatusName"></p>
                                                    <br />
                                                    <br />

                                                </div>
                                                <div class="b-l-info clearfix">
                                                    <div class="b-l-i-list">
                                                        <p>已完成</p>
                                                        <p class="size14" data-bind="StrProjectPercent">
                                                            117%
                                                        </p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>已筹集</p>
                                                        <p class="size14" data-bind="CurrentAmount">¥0</p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>剩余时间</p>
                                                        <p class="size14" data-bind="StrRemainDays">0 天</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td>
                                                <p class="b-l-price-red " data-bind="Amount">1.00</p>

                                            </td>
                                            <td>
                                                <p class="font-grey1" data-bind="ProjectStatusName"></p>
                                            </td>
                                            <td class="BianJi"></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="xjgrid-load" style="display: none;">
                                <img src="../../assets/layer/skin/default/xubox_loading2.gif">加载中...
                            </div>
                        </div>
                        <div id="gridlist_pagep" class="grid-pagination">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section script{
    <script src="~/Scripts/laypage/laypage.js"></script>
    <script src="~/Scripts/transparency.min.js"></script>
    <script type="text/javascript">
        var options = {
            listUrl: "@Url.Action("MyProject")",
        };
        $(function () {
            LoadData(1);
            $("#group a").click(function () {
                $("#group a").removeClass("ui-tab-list--now");
                $(this).addClass("ui-tab-list--now");
            });
            //点击发起项目
            $("#sponsorPro").click(function () {
                //判断是否开通盛付通
                if ('@IsIDValidate' == 'False') {
                    $.dialog.tips("亲~请先开通盛付通哦~", 2, "tips.gif", function () {
                        window.location.href = "../Account/AccountInfo";
                    });
                } else {
                    window.location.href = "../Project/Index";
                }
            });
        });
        var pages = 0;

        function LoadData(curr, status) {

            var url = options.listUrl;
            $.ajax({
                url: url,
                type: 'Post',
                dataType: 'json',
                data: {
                    sortname: "Id",
                    sortorder: "DESC",
                    title: false,
                    rp: 5,
                    usepager: true,
                    page: curr,
                    showcheckbox: false,
                    AuditStatus: status
                },
                success: function (result) {

                    if (result.DataList == null)
                        return;
                    var post = result.DataList;
                    var directives = {
                        ThumImage: {
                            html: function () {

                                return "<img style='width: 100px; height: 100px' src='" + this.ProjectThumImage + "  '>";
                            },
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        ProjectName: {
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        BianJi: {
                            html: function () {

                                return this.BianJi;
                            }
                        }
                    };
                    $('.DataList').render(post, directives);
                    if (result.TotalPage > 0) {
                        pages = result.TotalPage;
                    }
                    laypage({
                        cont: 'gridlist_pagep', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: pages, //通过后台拿到的总页数
                        curr: result.PageIndex + 1, //当前页
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr  
                                LoadData(obj.curr, status);
                            }
                        }
                    });
                }
            });
        }

        function selectMyProject(obj, status) {


        }

        function doDelete(obj) {
            alert(obj);
        }

        //删除项目
        function deleteProject(id) {
            $.dialog.confirm('亲~真的要删除吗？', function () {
                $.post("/UserProject/DeleteProject?Id=" + id, function (msg) {
                    location.href = location.href;
                });
            });
        }
    </script>
}